package com.client.service;

import com.client.pojo.StockWarningConfig;
import com.client.service.Impl.StockServiceFallBack;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(value = "stock-service",path = "stock",fallback = StockServiceFallBack.class)
public interface StockService {

    // 扣减库存接口，处理异常并返回合适的错误提示信息
    @PostMapping("/decrease")
    public ResponseEntity<String> decreaseStock(@RequestParam("productId") String productId,
                                                @RequestParam("quantity") int quantity);

    // 增加库存接口，返回操作结果信息
    @PostMapping("/increase")
    public ResponseEntity<String> increaseStock(@RequestParam("productId") String productId,
                                                @RequestParam("quantity") int quantity);

    // 获取商品库存数量接口，返回库存数量
    @GetMapping("/quantity/{productId}")
    public ResponseEntity<Integer> getStockQuantity(@PathVariable("productId") String productId);

    // 设置库存预警阈值接口，返回操作结果信息
    @PutMapping("/warning-threshold")
    public ResponseEntity<String> setStockWarningThreshold(@RequestParam("productId") String productId,
                                                           @RequestParam("threshold") int threshold);

    // 判断是否低于库存预警接口，返回判断结果
    @GetMapping("/below-warning/{productId}")
    public ResponseEntity<Boolean> isBelowStockWarning(@PathVariable("productId") String productId);

    // 批量扣减库存接口，处理异常并返回合适的提示信息
    @PostMapping("/batch-decrease")
    public ResponseEntity<String> batchDecreaseStock(@RequestBody List<String> productIds,
                                                     @RequestBody List<Integer> quantities);

    // 获取多个商品的库存预警配置信息接口，返回配置信息列表
    @GetMapping("/warning-configs")
    public ResponseEntity<List<StockWarningConfig>> getStockWarningConfigs(@RequestBody List<String> productIds);
}
